package cn.tedu.blog.server.repo;


import cn.tedu.blog.server.pojo.entity.ArticleItem;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface SearchRepository extends ElasticsearchRepository<ArticleItem,Long>  {


    @Query("{\n" +
            "    \"bool\": {\n" +
            "      \"should\": [\n" +
            "        { \"match\": { \"title\": \"?0\"}},\n" +
            "        { \"match\": { \"brief\": \"?0\"}}\n" +
            "        ]\n" +
            "     }\n" +
            "}")
        // 上面指定了查询语句,这个方法的方法名就随意定义了
    Page<ArticleItem> querySearch(String keyword, PageRequest pageable);
}
